﻿namespace TC
{
    public class SetString_blueprint : TranslateBlueprint
    {
        public override editor.cfg.blueprint.Node OnTranslate(Node node)
        {
            SetObject<string> t = node as SetObject<string>;
            editor.cfg.blueprint.SetStringVar re = new editor.cfg.blueprint.SetStringVar();
            re.id = t.id;
            Port p = t.graph.GetConnect(t.flowOut);
            if (p != null)
            {
                re.nextNode = p.parent.id;
            }
            //p = t.graph.GetConnect(t.key);
            //if(p == null)
            //{
            //    re.varName = t.key.defaultValue;
            //}
            re.varName = t.key;
            re.toCommonArea = false;
            p = t.graph.GetConnect(t.value);
            if (p == null)
            {
                re.from = new editor.cfg.blueprint.ConstString() { value = t.value.defaultValue };
            }
            else
            {
                re.from = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }

            return re;
        }
    }
}
